#pragma once

#include <iostream>
#include <fstream>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <boost/algorithm/string.hpp>
#include <jsoncpp/json/json.h>
#include "word_segmentation.hpp"

using std::string;
struct News_Info{
    string title;
    string author;
    string date;

    News_Info(string title_,string author_,string date_)
        :title(title_),
         author(author_),
         date(date_)
    {}
};

void Load( std::unordered_map<string,std::unordered_set<string>>& inverted_index,
           std::unordered_map<string,std::unordered_map<string,string>>& forward_index);

bool Find(std::unordered_map<string,std::unordered_set<string>> inverted_index,
          string keyword,std::unordered_map<string,int>& ids);

vector<std::pair<string,int> > Sort(std::unordered_map<string,int> ids);

vector<News_Info> ReturnInfo(const vector<std::pair<string,int> >& sort_ids,
                             std::unordered_map<string,std::unordered_map<string,string>> forward_index);
